package net.jescort.domain.forum;

import java.util.Map;
import net.gelif.kernel.core.domain.AbstractPersistable;
import net.jescort.domain.enumerator.CategoryStatus;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

//@Configurable(value = "category", autowire = Autowire.BY_TYPE)
public class Category extends AbstractPersistable<Integer> implements Comparable<Category>
{
    private static final long serialVersionUID = -3621817135558320156L;
    
    public Category()
    {
    }
    
    private Integer id;
    private String subject;
    private String summary;
    private int count;
    private Map<CategoryStatus, Boolean> status;
    private Map<String, String> properties;
    
    public Integer getId()
    {
        return id;
    }
    public void setId(Integer id)
    {
        this.id = id;
    }
    
    public String getSubject()
    {
        return subject;
    }
    public void setSubject(String subject)
    {
        this.subject = subject;
    }
    
    public String getSummary()
    {
        return summary;
    }
    public void setSummary(String summary)
    {
        this.summary = summary;
    }
    
    public int getCount()
    {
        return count;
    }
    public void setCount(int count)
    {
        this.count = count;
    }
    
    public Map<CategoryStatus, Boolean> getStatus()
    {
        return status;
    }
    public void setStatus(Map<CategoryStatus, Boolean> status)
    {
        this.status = status;
    }
    
    public Map<String, String> getProperties()
    {
        return properties;
    }
    public void setProperties(Map<String, String> properties)
    {
        this.properties = properties;
    }
    
    @Override
    public boolean equals(Object object)
    {
        if(this == object)
        {
            return true;
        }
        if(!(object instanceof Category))
        {
            return false;
        }
        final Category category = (Category)object;
        return new EqualsBuilder().append(id, category.getId()).isEquals();
    }
    
    @Override
    public int hashCode()
    {
        return new HashCodeBuilder().append(id).toHashCode();
    }
    
    @Override
    public String toString()
    {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", this.id).append("subject", this.subject).append("summary", this.summary).append("count", this.count).toString();
    }
    
    public int compareTo(Category category)
    {
        return new CompareToBuilder().append(getCount(), category.getCount()).toComparison();
    }
}
